package spring.boot.adminx.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;

import java.util.ArrayList;
import java.util.List;

@Data
@TableName("sys_menu")
public class SysMenu implements GrantedAuthority {

    @TableId
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    private String url;

    private String name;

    private String authority;

    @TableField("p_id")
    private Long pId;

    private Integer enable;

    private Integer level;

    @TableField(exist = false)
    private List<SysMenu> children = new ArrayList<>();

    @TableField(exist = false)
    private boolean isIsLeaf = true;

    public String getLabel(){
        return name;
    }

}
